ozi.o nmea.o text.o html.o palmdoc.o netstumbler.o hsa_ndv.o \
igc.o brauniger_iq.o
-FILTERS=position.o duplicate.o arcdist.o polygon.o smplrout.o reverse_route.o sort.o
+FILTERS=position.o duplicate.o arcdist.o polygon.o smplrout.o reverse_route.o sort.o stackfilter.o
JEEPS=jeeps/gpsapp.o jeeps/gpscom.o \
jeeps/gpsmath.o jeeps/gpsmem.o \
# Machine generated from here down.
arcdist.o: arcdist.c defs.h queue.h grtcirc.h
+brauniger_iq.o: brauniger_iq.c defs.h queue.h jeeps/gpsserial.h \
+ jeeps/gps.h jeeps/gpsport.h jeeps/gpssend.h jeeps/gpsread.h \
+ jeeps/gpsutil.h jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h \
+ jeeps/gpsfmt.h jeeps/gpsmath.h jeeps/gpsnmea.h jeeps/gpsmem.h \
+ jeeps/gpsrqst.h jeeps/gpsinput.h jeeps/gpsproj.h jeeps/gpsnmeafmt.h \
+ jeeps/gpsnmeaget.h
cetus.o: cetus.c defs.h queue.h coldsync/palm.h coldsync/pdb.h
copilot.o: copilot.c defs.h queue.h coldsync/palm.h coldsync/pdb.h
csv_util.o: csv_util.c defs.h queue.h csv_util.h grtcirc.h
jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
jeeps/gpsnmea.h jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsinput.h \
jeeps/gpsproj.h jeeps/gpsnmeafmt.h jeeps/gpsnmeaget.h
+igc.o: igc.c defs.h queue.h
internal_styles.o: internal_styles.c defs.h queue.h
magnav.o: magnav.c defs.h queue.h coldsync/palm.h coldsync/pdb.h
magproto.o: magproto.c defs.h queue.h magellan.h
saroute.o: saroute.c defs.h queue.h
smplrout.o: smplrout.c defs.h queue.h grtcirc.h
sort.o: sort.c defs.h queue.h
+stackfilter.o: stackfilter.c defs.h queue.h
text.o: text.c defs.h queue.h jeeps/gpsmath.h jeeps/gps.h jeeps/gpsport.h \
jeeps/gpsserial.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
jeeps/gpsserial.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
jeeps/gpsmath.h jeeps/gpsnmea.h jeeps/gpsmem.h jeeps/gpsrqst.h \
- jeeps/gpsinput.h jeeps/gpsproj.h jeeps/gpsnmeafmt.h jeeps/gpsnmeaget.h
+ jeeps/gpsinput.h jeeps/gpsproj.h jeeps/gpsnmeafmt.h jeeps/gpsnmeaget.h \
+ jeeps/garminusb.h
jeeps/gpsprot.o: jeeps/gpsprot.c jeeps/gps.h defs.h queue.h \
jeeps/gpsport.h jeeps/gpsserial.h jeeps/gpssend.h jeeps/gpsread.h \
jeeps/gpsutil.h jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h \
--- /dev/null
+/*
+ Stack filter
+
+ Copyright (C) 2002 Robert Lipe, robertlipe@usa.net
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
+
+ */
+#include <stdio.h>
+#include "defs.h"
+
+#define MYNAME "Stack filter"
+
+extern queue waypt_head;
+
+static char *opt_push = NULL;
+static char *opt_copy = NULL;
+static char *opt_pop = NULL;
+static char *opt_append = NULL;
+static char *opt_discard = NULL;
+static char *opt_replace = NULL;
+static char *opt_swap = NULL;
+static char *opt_depth = NULL;
+static int swapdepth = 0;
+
+static
+arglist_t stackfilt_args[] = {
+ {"push", &opt_push, "Push waypoint list onto stack", ARGTYPE_BOOL},
+ {"copy", &opt_copy, "Copy waypoint list when pushing", ARGTYPE_BOOL},
+ {"pop", &opt_pop, "Pop waypoint list from stack", ARGTYPE_BOOL},
+ {"append", &opt_append, "Append list when popping", ARGTYPE_BOOL},
+ {"discard", &opt_discard, "Discard top of stack when popping", ARGTYPE_BOOL},
+ {"replace", &opt_replace, "Replace list with top of stack (default)", ARGTYPE_BOOL},
+ {"swap", &opt_swap, "Swap waypoint list with <depth> element of stack", ARGTYPE_BOOL},
+ {"depth", &opt_depth, "Element to use in swap operation", ARGTYPE_INT},
+ {0, 0, 0, 0}
+};
+
+struct stack_elt {
+ queue waypts;
+ struct stack_elt *next;
+} *stack = NULL;
+
+
+void
+stackfilt_process(void)
+{
+ struct stack_elt *tmp_elt = NULL;
+ queue *elem = NULL;
+ queue *tmp = NULL;
+ queue tmp_queue;
+ waypoint *wpt_tmp;
+
+ if ( opt_push ) {
+ tmp_elt = (struct stack_elt *)xmalloc(sizeof(struct stack_elt));
+ QUEUE_MOVE(&(tmp_elt->waypts), &waypt_head);
+ tmp_elt->next = stack;
+ stack = tmp_elt;
+ if ( opt_copy ) {
+ QUEUE_FOR_EACH( &(stack->waypts), elem, tmp ) {
+ waypt_add( waypt_dupe((waypoint *)elem));
+ }
+ }
+ }
+ else if ( opt_pop ) {
+ tmp_elt = stack;
+ if ( !tmp_elt ) {
+ fatal( MYNAME ": stack empty\n");
+ }
+ if ( opt_append ) {
+ QUEUE_FOR_EACH( &(stack->waypts), elem, tmp ) {
+ waypt_add( (waypoint *)elem);
+ }
+ }
+ else if ( opt_discard ) {
+ waypt_flush( &(stack->waypts) );
+ }
+ else {
+ waypt_flush( &waypt_head );
+ QUEUE_MOVE(&(waypt_head), &(stack->waypts) );
+ }
+ stack = tmp_elt->next;
+ xfree( tmp_elt );
+ }
+ else if ( opt_swap ) {
+ tmp_elt = stack;
+ while ( swapdepth > 1 ) {
+ if ( !tmp_elt->next ) {
+ fatal (MYNAME ": swap with nonexistent element\n");
+ }
+ tmp_elt = tmp_elt->next;
+ swapdepth--;
+ }
+ QUEUE_MOVE(&tmp_queue, &(tmp_elt->waypts) );
+ QUEUE_MOVE(&(tmp_elt->waypts), &waypt_head );
+ QUEUE_MOVE(&waypt_head, &tmp_queue );
+ }
+}
+
+void
+stackfilt_init(const char *args) {
+
+ int invalid = 0;
+
+ if ( opt_depth ) {
+ swapdepth = atoi( opt_depth );
+ }
+ if ( opt_push ) {
+ if ( opt_pop || opt_append || opt_discard || opt_replace ||
+ opt_swap || opt_depth ) {
+ invalid = 1;
+ }
+ }
+ else if ( opt_pop ) {
+ if ( opt_push || opt_copy || opt_swap || opt_depth ) {
+ invalid = 1;
+ }
+ if ( !!opt_append + !!opt_discard + !!opt_replace > 1 ) {
+ invalid = 1;
+ }
+ }
+ else if ( opt_swap ) {
+ if ( opt_push || opt_copy || opt_pop || opt_append ||
+ opt_discard || opt_replace ) {
+ invalid = 1;
+ }
+ }
+ else {
+ invalid = 1;
+ }
+
+ if ( invalid ) {
+ fatal (MYNAME ": invalid combination of options\n");
+ }
+
+}
+
+void
+stackfilt_deinit(void) {
+ swapdepth = 0;
+}
+
+void
+stackfilt_exit( void ) {
+ struct stack_elt *tmp_elt = NULL;
+
+ if ( stack ) {
+ warning( MYNAME " Warning: leftover stack entries; "
+ "check command line for mistakes\n" );
+ }
+ while ( stack ) {
+ waypt_flush( &(stack->waypts) );
+ tmp_elt = stack;
+ stack = stack->next;
+ xfree(tmp_elt);
+ }
+}
+
+filter_vecs_t stackfilt_vecs = {
+ stackfilt_init,
+ stackfilt_process,
+ stackfilt_deinit,
+ stackfilt_exit,
+ stackfilt_args
+};